package richbar.com.richbar.activity.me.myassets;

import android.view.View;
import android.widget.TextView;

import com.common.base.BaseActivity;
import com.common.util.ToastUtil;
import com.okhttp.network.HttpUtils;
import com.okhttp.network.MyGson;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import richbar.com.richbar.R;
import richbar.com.richbar.activity.me.ChangePayPwdAc;
import richbar.com.richbar.activity.me.GoHtmlAc;
import richbar.com.richbar.base.BaseApplication;
import richbar.com.richbar.bean.PersonBean;
import richbar.com.richbar.help.TitleHelp;
import richbar.com.richbar.util.LoadingDialog;
import richbar.com.richbar.util.NetWorkUtil;

/**
 * Created by Administrator on 2018/11/28.
 */

public class MyAssetsAc extends BaseActivity {
    @BindView(R.id.tv_p)
    TextView tv_p;
    @BindView(R.id.tv_p1)
    TextView tv_p1;
    @BindView(R.id.tv_p2)
    TextView tv_p2;
    @BindView(R.id.tv_p3)
    TextView tv_p3;
    @BindView(R.id.tv_p4)
    TextView tv_p4;
    private LoadingDialog dialog;

    @Override
    public int initLayout() {
        return R.layout.ac_my_assets;

    }

    @Override
    public void initTitle() {
        new TitleHelp(this).setTitle("个人收入");
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        dialog = new LoadingDialog(MyAssetsAc.this, 0);
        dialog.show();
        NetWorkUtil.getPerson(new HttpUtils.HttpCallback() {
            @Override
            public void onSuccess(String data) {
                dialog.dismiss();
                final PersonBean personBean = MyGson.getInstance().fromJson(data, PersonBean.class);
                tv_p.setText(personBean.getData().getRecharge_balance() + "");
                tv_p1.setText(personBean.getData().getTobe_balance() + "");
                tv_p2.setText(personBean.getData().getBalance() + "");
                tv_p3.setText(personBean.getData().getGold_balance() + "");
                tv_p4.setText(personBean.getData().getSeller_balance() + "");
            }

            @Override
            public void onError(String msg) {
                super.onError(msg);
                dialog.dismiss();
                ToastUtil.showToast(MyAssetsAc.this, msg);
            }
        });
    }

    @OnClick({R.id.ly1, R.id.ly2, R.id.ly3, R.id.ly4, R.id.ly5, R.id.ly6, R.id.ly7})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ly1://充值余额
                start(RepaidBalanceAc.class);
                break;
            case R.id.ly2://待返金额
                start(AmountReturnedAc.class);
                break;
            case R.id.ly3://可用金额
                start(AvailableMoneyAc.class);
                break;
            case R.id.ly4://金币账户 用html写
                GoHtmlAc.start(MyAssetsAc.this, NetWorkUtil.URL + "/home/account/index&uid=" + BaseApplication.uid, "金币账户");
                break;
            case R.id.ly5://积分账户
                start(IntegralAccountAc.class);
                break;
            case R.id.ly6://店铺收益 用html写
                GoHtmlAc.start(MyAssetsAc.this, NetWorkUtil.URL + "/home/shop/index&uid=" + BaseApplication.uid, "店铺收益");
                break;
            case R.id.ly7://代理账户 用html写
                GoHtmlAc.start(MyAssetsAc.this, NetWorkUtil.URL + "/home/agent/index&uid=" + BaseApplication.uid, "代理账户");
                break;
        }
    }
}
